import React, { lazy, Suspense } from 'react';
import { PageLoading } from "@ecoding/components.antd.layout";

function dynamic(
    loadComponent: () => Promise<{
        default: React.ComponentType<any>;
    }>
) {
    const LazyComponent = lazy(loadComponent);
    return (props) => (
        <Suspense fallback={<PageLoading />}>
            <LazyComponent {...props} />
        </Suspense>
    );
}

const LazyEditor: React.ComponentType<any> = dynamic(() =>
    import(/* webpackChunkName: 'monaco' */ '@ecoding/components.monaco').then((Modules) => {
        return {
            default: Modules.MonacoEditor
        };
    })
);

const C = () => {
    return <LazyEditor style={{height: 150}} />;
}

export default C;

